package rickyl.graduate;

import android.app.Activity;
import android.view.*;
import android.widget.*;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Environment;

import java.util.*;
import java.io.*;

public class GP0408Activity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        //inflate main view
        setContentView(R.layout.main);
        
        int frequency = 11025;
        int channelConfiguration = AudioFormat.CHANNEL_IN_MONO;
        int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
        File file = new File(Environment.getExternalStorageDirectory(), "raw.pcm");
        
        try
        {
        	file.createNewFile();
        }
        catch (IOException e) {}
        
        try
        {
        	OutputStream os = new FileOutputStream(file);
        	BufferedOutputStream bos = new BufferedOutputStream(os);
        	DataOutputStream dos = new DataOutputStream(bos);
        	
        	int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
        	
        	short[] buffer = new short[bufferSize];
        	
        	AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
        											  frequency,
        											  channelConfiguration,
        											  audioEncoding,
        											  bufferSize);
        	audioRecord.startRecording();
        	
        	
        }
        catch (Throwable t) {}
        
        
        
    }
}